/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Lyn
 * Date: 2025-01-18
 * Time: 9:49
 */
class Animal{
    public String name;
    public int age;
    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
    }
    public void eat(){
        System.out.println(name+"正在吃！");
    }
    @Override
    public String toString() {
        return "Animal{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
class Dog extends Animal{
    public Dog(String name,int age){
        super(name, age);
    }
    public void wangWang(){
        System.out.println(name+"正在旺旺！！");
    }
}
class Bird extends Animal{
    public Bird(String name, int age) {
        super(name, age);
    }
    public void fly(){
        System.out.println(name+"正在飞!!");
    }
}
public class text {
    public static void main(String[] args) {
        //向上转型
       /* Dog dog = new Dog("小狗",10);
        Animal animal = dog;*/

        //父类引用 引用了子类对象
        //Animal animal = new Dog("小狗",10);
        Animal animal1 = new Dog("小狗",10);
        Animal animal2 = new Bird("小鸟",10);

        Dog dog = new Dog("小狗",10);
        Bird bird = new Bird("小鸟",10);

        func1(dog);
        func1(bird);
    }
    public static void func1(Animal animal){

    }
    public static void main1(String[] args) {
        Dog dog = new Dog("小狗",10);
        dog.eat();
        dog.wangWang();
        System.out.println("===============");
        Animal animal = new Animal("animal",10);
        animal.eat();
    }
}
